package net.m2technologies.open_arm.transport.transaction.snmp;

import java.util.Properties;

/**
 * Copyright 2005 Mark Masterson<br> <br> Licensed under the Apache License, Version 2.0 (the "License");<br> you may
 * not use this file except in compliance with the License.<br> You may obtain a copy of the License at<br> <br>
 * http://www.apache.org/licenses/LICENSE-2.0<br> <br> Unless required by applicable law or agreed to in writing,
 * software<br> distributed under the License is distributed on an "AS IS" BASIS,<br> WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, either express or implied.<br> See the License for the specific language governing permissions and<br>
 * limitations under the License.<br>
 * <p/>
 * <p>Description: </p>
 *
 * @author Mark Masterson
 * @version 0.010
 */
public class SnmpMediatorConfiguration {

    /**
     * Value = "net.m2technologies.open_arm.transport.transaction.snmp.SnmpMediator"
     */
    public static final String CLASS_NAME_PROPERTY_KEY_PREFIX = SnmpMediator.class.getName();

    private final String managementHost;
    private final int managementHostTrapListenPort;
    private final String enterpriseOID;
    private final String applicationTrapOIDValue;
    private final long transactionLengthInterval;
    private final long updateLengthInterval;
    private final boolean isBlockedEventTrap;

    public SnmpMediatorConfiguration(final String managementHost,
                                     final int managementHostTrapListenPort,
                                     final String enterpriseOID,
                                     final String applicationTrapOIDValue,
                                     final long transactionLengthInterval,
                                     final long updateLengthInterval,
                                     final boolean blockedEventTrap) {
        this.managementHost = managementHost;
        this.managementHostTrapListenPort = managementHostTrapListenPort;
        this.enterpriseOID = enterpriseOID;
        this.applicationTrapOIDValue = applicationTrapOIDValue;
        this.transactionLengthInterval = transactionLengthInterval;
        this.updateLengthInterval = updateLengthInterval;
        isBlockedEventTrap = blockedEventTrap;
    }

    public Properties getProperties() {
        final Properties properties = new Properties();
        properties.setProperty(new StringBuffer()
                .append(SnmpMediatorConfiguration.CLASS_NAME_PROPERTY_KEY_PREFIX)
                .append(".managementHost")
                .toString(), this.managementHost);
        properties.setProperty(new StringBuffer()
                .append(SnmpMediatorConfiguration.CLASS_NAME_PROPERTY_KEY_PREFIX)
                .append(".managementHostTrapListenPort")
                .toString(), new StringBuffer().append("").append(this.managementHostTrapListenPort).toString());
        properties.setProperty(new StringBuffer()
                .append(SnmpMediatorConfiguration.CLASS_NAME_PROPERTY_KEY_PREFIX)
                .append(".enterpriseOID")
                .toString(), this.enterpriseOID);
        properties.setProperty(new StringBuffer()
                .append(SnmpMediatorConfiguration.CLASS_NAME_PROPERTY_KEY_PREFIX)
                .append(".applicationTrapOIDValue")
                .toString(), this.applicationTrapOIDValue);
        properties.setProperty(new StringBuffer()
                .append(SnmpMediatorConfiguration.CLASS_NAME_PROPERTY_KEY_PREFIX)
                .append(".transactionLengthInterval")
                .toString(), new StringBuffer().append("").append(this.transactionLengthInterval).toString());
        properties.setProperty(new StringBuffer()
                .append(SnmpMediatorConfiguration.CLASS_NAME_PROPERTY_KEY_PREFIX)
                .append(".updateLengthInterval")
                .toString(), new StringBuffer().append("").append(this.updateLengthInterval).toString());
        properties.setProperty(new StringBuffer()
                .append(SnmpMediatorConfiguration.CLASS_NAME_PROPERTY_KEY_PREFIX)
                .append(".isBlockedEventTrap")
                .toString(), new StringBuffer().append("").append(this.isBlockedEventTrap).toString());
        return properties;
    }

}
